@using Elsa.Studio.DomInterop.Contracts
<MudSimpleTable Outlined="true" Striped="false" Dense="true" Elevation="0" Bordered="false">
    <tbody>
    @{
        var data = HideEmptyValues ? Data.Where(x => !string.IsNullOrWhiteSpace(x.Value)) : Data;
    }
    @foreach (var item in data)
    {
        <tr>
            <td style="width: 200px;">@item.Key</td>
            <td style="width: 50px;">
                <MudIconButton Icon="@Icons.Material.Outlined.ContentCopy" Size="Size.Small" Title="Copy" OnClick="@(() => OnCopyClicked(item.Value!))" Disabled="@(string.IsNullOrWhiteSpace(item.Value))"/>
            </td>
            <td>@item.Value</td>
        </tr>
    }
    </tbody>
</MudSimpleTable>

@code {

    /// <summary>
    /// The data to display.
    /// </summary>
    [Parameter]
    public IDictionary<string, string?> Data { get; set; } = new Dictionary<string, string?>();

    /// <summary>
    /// If true, empty values will be hidden.
    /// </summary>
    [Parameter]
    public bool HideEmptyValues { get; set; }

    [Inject]
    private IClipboard Clipboard { get; set; } = default!;

    private async Task OnCopyClicked(string value)
    {
        await Clipboard.CopyText(value);
    }

}